package com.softwareweb.servlet;

import java.io.IOException;
import java.sql.Date;

import com.softwareweb.model.*;
import com.softwareweb.dao.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class UserRegister
 */
public class UserRegister extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public UserRegister() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.setContentType("test/html");
		request.setCharacterEncoding("UTF-8");
		String name=request.getParameter("userName");
		String pass=request.getParameter("password1");
		String email=request.getParameter("email");
		String city=request.getParameter("city");
		String occupation=request.getParameter("occupationSelect");
		String safeQuestion =request.getParameter("question");
		String safeAnswer=request.getParameter("answer");
		java.util.Date d=new java.util.Date();
		Date date=new Date(d.getYear(),d.getMonth(),d.getDate());
		String address=request.getParameter("address");
		String mobile=request.getParameter("mobile");
		String phone=request.getParameter("phone");
		String QQ=request.getParameter("QQ");
		String MSN=request.getParameter("MSN");
		String introduction=request.getParameter("introduction");
		
		UserInfo user=new UserInfo(name,pass,email,city,mobile,phone,QQ,MSN,
				address,null,occupation,introduction,0,0,UserInfo.NORMALMEMBER,
				UserInfo.PERSON,0,0,10,date,safeQuestion,safeAnswer);
		ConnDB conn=new ConnDB();
		int result=conn.insertUser(user);
		System.out.print(result);
		
	}

}
